; NLS
;
FALSE    EQU 0
TRUE     EQU 1
CR       EQU $8D
;
;
; "IF" STATEMENT EQUATES
;
EQ       EQU "="
NE       EQU "#"
GT       EQU ">"
LT       EQU "<"
GE       EQU ">"|"="*256
LE       EQU "<"|"="*256
;
;
;
;
;
;
;
; SPEED/ASM ENTRY POINTS
;
;
;
; NOTE: THE EQUATE OF PUTC MUST
; BE CHANGED IF YOU RELOCATE
; SPEED/ASM TO SOME LOCATION
; OTHER THAN $7800
;
PUTC     EQU $7000
GETC     EQU PUTC+3
SAGL     EQU GETC+3          ;FOR USE BY S/A ONLY
SAPC     EQU SAGL+3          ; "   "   "  "   "     "   "
HOME     EQU SAPC+3          ;HOME AND CLEAR
READLN   EQU HOME+3
INIT     EQU READLN+3
FOR      EQU INIT+3
FOR0     EQU FOR+3
NEXT     EQU FOR0+3
IFI      EQU NEXT+3
IFI0     EQU IFI+3
IFS      EQU IFI0+3
IFS0     EQU IFS+3
MOVE     EQU IFS0+3
LOAD     EQU MOVE+3
MOVS     EQU LOAD+3
LDSTR    EQU MOVS+3
PRINT    EQU LDSTR+3
PRTSTR   EQU PRINT+3
PRTINT   EQU PRTSTR+3
RDSTR    EQU PRTINT+3
RDINT    EQU RDSTR+3
ONXGOTO  EQU RDINT+3
CASE     EQU ONXGOTO+3
CASEI    EQU CASE+3
INSET    EQU CASEI+3
NOTINSET EQU INSET+3
;
;
;
         JSR INIT
         JSR HOME
         JSR PRINT
         BYT CR,"Flow of control test program",CR,CR,0
;
;
         JSR PRINT
         BYT "Testing ONXGOTO:",CR,CR,0
         LDX #10
XLOOP    JSR ONXGOTO
         ADR 8,X0,X1,X2,X3,X4,X5,X6,X7
         STX I
         LDA #0
         STA I+1
         JSR PRINT
         BYT "When I=",0
         JSR PRTINT
         ADR I
         JSR PRINT
         BYT " ONXGOTO passed through",CR,0
         JMP NEXTX
;
X0       JSR PRINT
         BYT "X=0",0
         JMP NEXTX
;
X1       JSR PRINT
         BYT "X=1",0
         JMP NEXTX
;
X2       JSR PRINT
         BYT "X=2",0
         JMP NEXTX
;
X3       JSR PRINT
         BYT "X=3",0
         JMP NEXTX
;
X4       JSR PRINT
         BYT "X=4",0
         JMP NEXTX
;
X5       JSR PRINT
         BYT "X=5",0
         JMP NEXTX
;
X6       JSR PRINT
         BYT "X=6",0
         JMP NEXTX
;
X7       JSR PRINT
         BYT "X=7",0
;
NEXTX    LDA #CR
         JSR PUTC
         DEX 
         BMI >0
         JMP XLOOP
;
;
^0:
;
         JSR GETRTN
;
;
         JSR PRINT
         BYT CR
         BYT "Testing CASE:",CR,CR,0
;
         LDX #7
CASELOOP TXA 
         JSR CASE
         BYT 4
         .DA #4,C4
         .DA #0,C0
         .DA #5,C5
         .DA #2,C2
         JSR PRINT
         BYT "When Acc=",0
         STA I
         LDA #0
         STA I+1
         JSR PRTINT
         ADR I
         JSR PRINT
         BYT " CASE passed through",CR,0
         JMP ENDCASE
;
C4       JSR PRINT
         BYT "Acc=4",CR,0
         JMP ENDCASE
;
C2       JSR PRINT
         BYT "Acc=2",CR,0
         JMP ENDCASE
;
C0       JSR PRINT
         BYT "Acc=0",CR,0
         JMP ENDCASE
;
C5       JSR PRINT
         BYT "Acc=5",CR,0
;
ENDCASE  DEX 
         BPL CASELOOP
;
         JSR GETRTN
;
;
         JSR PRINT
         BYT CR
         BYT "Testing the CASEI routine:",CR,CR,0
;
         JSR FOR0
         ADR I,!-1,10
;
         JSR CASEI
         ADR 4,I
         ADR 3,CI3
         ADR 0,CI0
         ADR 8,CI8
         ADR 6,CI6
         JSR PRINT
         BYT "When I equaled ",0
         JSR PRTINT
         ADR I
         JSR PRINT
         BYT " CASEI fell through",CR,0
         JMP NEXTCI
;
CI0      JSR PRINT
         BYT "I=0",CR,0
         JMP NEXTCI
;
CI3      JSR PRINT
         BYT "I=3",CR,0
         JMP NEXTCI
;
CI4      JSR PRINT
         BYT "I=4",CR,0
         JMP NEXTCI
;
CI6      JSR PRINT
         BYT "I=6",CR,0
         JMP NEXTCI
;
CI8      JSR PRINT
         BYT "I=8",CR,0
;
NEXTCI   JSR NEXT
         JSR GETRTN
;
;
         JSR PRINT
         BYT CR,"Testing INSET:",CR,0
;
         LDX #10
INSETLP  TXA 
         JSR INSET
         BYT 5
         BYT 0,5,9,2,25
         ADR ISINSET
         JSR PRINT
         BYT "When Acc=",0
         STX I
         JSR PRTINT
         ADR I
         JSR PRINT
         BYT " INSET fell through",CR,0
         JMP NEXTINS
;
ISINSET  JSR PRINT
         BYT "INSET matched when Acc=",0
         STX I
         JSR PRTINT
         ADR I
         LDA #CR
         JSR PUTC
;
NEXTINS  DEX 
         BPL INSETLP
         JSR GETRTN
;
;
;
         JSR PRINT
         BYT CR
         BYT "Testing NOTINSET:",CR,CR,0
;
         JSR FOR0
         ADR I,"A","D"
;
         LDA I
         JSR NOTINSET
         STR "ASDFGHJKL"
         ADR ISNTHERE
;
         LDA #"""
         JSR PUTC
         LDA I
         JSR PUTC
         JSR PRINT
         BYT """ was found in the set, so NOTINSET",CR
         BYT "fell through.",CR,0
         JMP NEXTNIS
;
ISNTHERE:
         LDA #"""
         JSR PUTC
         LDA I
         JSR PUTC
         JSR PRINT
         BYT """ wasn't found in the list",CR,0
;
NEXTNIS  JSR NEXT
         JSR GETRTN
         JSR PRINT
         BYT CR,CR,CR,CR
         BYT "That's all folks...",CR,0
         RTS 
;
;
;
GETRTN   JSR PRINT
         BYT CR,CR,"(Press return to continue):",0
         JSR READLN
         JSR HOME
         RTS 
;
;
;
I        ADR 0
         END